package com.yuexun.dhdoctor.module.login.presenter.impl;


import com.yuexun.dhdoctor.module.login.model.IMenuPhoneModel;
import com.yuexun.dhdoctor.module.login.presenter.IMenuPhonePresenter;
import com.yuexun.dhdoctor.module.login.ui.view.IMenuPhoneView;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/12/12.
 */
public class MenuPhonePresenter implements IMenuPhonePresenter {
    private IMenuPhoneView view;
    private IMenuPhoneModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public MenuPhonePresenter(IMenuPhoneModel model, IMenuPhoneView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void getMenuPhone(Map<String, String> praise) {
        model.getMenuPhone(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<String>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        view.getMenuPhone("");
                    }

                    @Override
                    public void onNext(String s) {
                        view.getMenuPhone(s);
                    }
                });
    }
}
